import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { join ,resolve} from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'

const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  base: '/',
  plugins: [
    vue(), 
    viteCommonjs(),
    vueJsx(),
     /** svg 图标配置 */
     createSvgIconsPlugin({
      iconDirs: [resolve(process.cwd(), "src/assets/svg-icons")],
      symbolId: "icon-[dir]-[name]",
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },

  server: {
    proxy: {
      '/api': {
        // target: 'http://localhost:8010',
        target: 'http://localhost:8989',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
      ,
      '/workflowserver': {
        target: 'http://localhost:8989',
        // protocolRewrite:"https",
        secure: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/workflowserver/, '')
      }
    }
  }
})
